package geographer;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Project #3
 * CS 2334, 010
 * 03/26/2014
 * <P>
 * This class represents the country class. It inherits from GeographicRegion.
 * </P>
 * @version 2.0
 */
public class Country extends GeographicRegion implements Serializable {
	
	/**
	 * The unique serial id.
	 */
	private static final long serialVersionUID = 1L;

	/*List of Cities within the country*/
	private List<String> cities;
	
	/*The continent the country belongs to*/
	private String continent;


	
	/**
	 * Constructor for the Country
	 * <P>
	 * Country constructor
	 * </P>
	 * @params	data	Data passed into the constructor
	*/
	public Country(String... data) {
		super(data[0], data[1], data[2]); //send data array to the super constructor
		cities = new ArrayList<String>(); //create the ArrayList of cities
		continent = data[3]; //Assign the belonging continent
	}//end constructor
	
	public void edit(String[] data)
	{
		super.edit(data[0], data[1], data[2]);
		continent = data[3];
		cities = new ArrayList<String>();
		this.add(data[4]);
	}
	
	/**
	 * Adds <code>City</code> to <code>Continent</code>
	 * <P>
	 * Algorithm:<br>
	 * 1. Add <code>City</code> to the ArrayList<br>
	 * </P>
	 * @param	city	<code>City</code> to add to the continent
	 * @return	boolean	Success of the operation
	 * <dt><b>Conditions:</b>
	 * <dd>PRE -   <code>city</code> must be a non - null value
	 * <dd>POST  -   The specified <code>City</code> object was added to the array
	 */
	public boolean add(String city){
		return cities.add(city);
	}//end add
	
	/**
	 * Gets subregions of the country
	 * <P>
	 * Algorithm:<br>
	 * 1. Return the subregions of the country<br>
	 * </P>
	 * @return	cities	<code>City</code> list of subregions
	 * <dt><b>Conditions:</b>
	 * <dd>POST  -   The correct subregions were returned
	 */
	public List<String> getSubregions(){
		return cities;
	}//end getSubregions
	
	/**
	 * Gets super region of the country
	 * <P>
	 * Algorithm:<br>
	 * 1. Return the super region of the country<br>
	 * </P>
	 * @return	continent	 The super region of the country
	 * <dt><b>Conditions:</b>
	 * <dd>POST  -   The correct super region was returned
	 */
	public String getSuperRegion(){
		return continent;
	}//end getSuperRegion
	
	/**
	 * Returns the contents of the <code>Country</code> object as a string.
	 * <P>
	 * Algorithm:<br>
	 * 1. Create a string containing all values within this object <br>
	 * 2. Return the string<br>
	 * </P>
	 *@return   String A string containing all information in the <code>Country</code> object.
	 * <dt><b>Conditions:</b>
	 * <dd>POST -          A String continaing all information for this object is returned.
	 */
	@Override
	public String toString() {
		return  this.getName() +", "+ 
				this.getArea() +", "+ 
				this.getPopulation() +", "+
				this.continent;
	}//end toString	
}//end Country
